﻿using ReflectionStudio.Core.Events;
using System;
using System.Data;
using System.Windows;
using System.Windows.Data;
using System.ComponentModel;
namespace WPFExcelReport
{
    public partial class K0109
    {
        public K0109()
        {
            if (DesignerProperties.GetIsInDesignMode(this))
                return;
            InitializeComponent();
            SDSA = "0109";
        }
        public override void LOADALL()
        {
            base.LOADALL();
            if (LMS.Length > 0)
            {
                filter = "SDKEY LIKE '%" + LMS + "'";
                rows = TBMain.Select(filter);
                if (rows.Length > 0)
                {
                    TBTemp = rows.CopyToDataTable();
                    TBMain.Clear();
                    TBMain.Merge(TBTemp);
                }
            }
            foreach (DataRow row in TBMain.Rows)
            {
                row["SDES"] = Helpers.Helper.Convert8859P1ToGB2312(row["SDES"].ToString().Trim());
                row["DES"] = Helpers.Helper.Convert8859P1ToGB2312(row["DES"].ToString().Trim());
            }
        }
        public override void ManageCommand(object sender, RoutedEventArgs e)
        {
            if (IsManage)
            {
                if (DBSDDAT.ContainsKey(SDSA))
                {
                    DBSDDAT.Remove(SDSA);
                    return;
                }
                LOADALL();
                IsManage = false;
            }
            else
            {
                IsManage = true;
                switch (LMS)
                {
                    case "D":
                        VICC_WFEVENTS.SVWF.DFD(RUNID, KEY);
                        break;
                    case "P":
                        VICC_WFEVENTS.SVWF.PGD(RUNID, KEY);
                        break;
                    case "W":
                        VICC_WFEVENTS.SVWF.WVD(RUNID, KEY);
                        break;
                }

            }

        }
    }
}
